class_name SelectCharacterArea
extends Area2D


@export var target_char: Character

var _is_mouse_entered: bool

signal selected_character(character: Character)


func _ready() -> void:
    mouse_entered.connect(func() -> void: _is_mouse_entered = true)
    mouse_exited.connect(func() -> void: _is_mouse_entered = false)


func _input(event: InputEvent) -> void:
    if not _is_mouse_entered: return
    if event is InputEventMouseButton and \
        event.button_index == MOUSE_BUTTON_LEFT and \
        event.pressed:
        selected_character.emit(target_char)
        #print("selected character: ", target_char.data.name_str)
